package com.autocar.reader.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.autocar.reader.R;
import com.autocar.reader.bean.ProductDetailBean;
import com.autocar.reader.camera.CaptureActivity;
import com.org.any.autocar.ChatListActivity;
import com.org.any.autocar.ChatLookPersonAddActivity;
import com.org.any.autocar.PersonSpaceActivity;
import com.org.any.autocar.ProductSupplyActivity;
import com.org.any.autocar.UserInfoActivity;
import com.org.any.autocar.SearchResultActivity;
import com.org.any.autocar.WebGouMaiActivity;

public class UIHelper {
	public static void toAuthorInfo(Context context, String fuid) {
		Intent intent = new Intent(context, ChatLookPersonAddActivity.class);
		intent.putExtra("fuid", fuid);
		Log.i("test", fuid);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void gotoTwoCode(Context context) {
		Intent intent = new Intent(context, CaptureActivity.class);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void gotoPersonCenter(Context context) {
		Intent intent = new Intent(context, UserInfoActivity.class);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void gotoPersonSpace(Context context,String uid,String username) {
		Intent intent = new Intent(context, PersonSpaceActivity.class);
		intent.putExtra("uid", uid);
		intent.putExtra("username", username);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}
	
	public static void toWarn(Context context, String uid) {
		Intent intent = new Intent(context, ProductSupplyActivity.class);
		intent.putExtra("id", uid);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void toChatList(Context context, String uid, String username) {
		Intent intent = new Intent(context, ChatListActivity.class);
		intent.putExtra("uid", uid);
		intent.putExtra("username", username);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void gotoSearchResultByProduct(Context context,
			ProductDetailBean bean) {
		Intent intent = new Intent(context, SearchResultActivity.class);
		intent.putExtra("bean", bean);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}

	public static void gotoWebUrl(Context context, String url) {
		Intent intent = new Intent(context, WebGouMaiActivity.class);
		intent.putExtra("url", url);
		context.startActivity(intent);
		((Activity) context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}
	
	public static void gotoWebActivity(Context context,String url) {
		Intent viewIntent = new Intent("android.intent.action.VIEW");
		Uri uri = Uri.parse(url);
		viewIntent.setDataAndType(uri, "text/html");
		context.startActivity(viewIntent);
		((Activity)context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}
	
	public static void gotoChat(Context context,String username, String uid,String photo) {
		Intent intent = new Intent(context, ChatListActivity.class);
		intent.putExtra("username", username);
		intent.putExtra("uid", uid);
		intent.putExtra("photo", photo);
		context.startActivity(intent);
		((Activity)context).overridePendingTransition(R.anim.right_in_anim,
				R.anim.fade_out);
	}
}
